#include "pch.h"
#include "PolyLineGraphData.h"

namespace PolyLineGraph2
{
	PolyLineGraphData::PolyLineGraphData()
	{
		InitializePolyLineGraphDataContainer();
		columeNames = ref new ListCollection<Platform::String^>; 
		pointValues1 = ref new ListCollection<double>;
		pointValues2 = ref new ListCollection<double>;
		rowColors  = ref new ListCollection<Windows::UI::Color>; 
		rowNames = ref new ListCollection<Platform::String^>;
	}

	void PolyLineGraphData::InitializePolyLineGraphDataContainer()
	{

	}

	void PolyLineGraphData::addRow(Platform::String^ m_rowName, Windows::UI::Color m_rowColor)
	{
		//ListCollection<double> columeDatas;
		//pointValues.Append(columeDatas);


		rowColors->Append(m_rowColor);
		rowNames->Append(m_rowName);
	}

	void PolyLineGraphData::addColume(Platform::String^ m_columeName, ListCollection<double>^ m_columeValues)
	{
		//add a colume
		columeNames->Append(m_columeName);
		pointValues1->Append(m_columeValues->GetAt(0));
		pointValues2->Append(m_columeValues->GetAt(1));
		//for(unsigned int i = 0; i < m_columeValues.Length; i++)
		//{
		//	pointValues.GetAt(i).Add(m_columeValues.get(i));
		//}
	}

	double PolyLineGraphData::getMaxValue()
	{
		double maxValue = 0.0;
		for(unsigned int i = 0; i < pointValues1->Size; i++)
		{
			if(maxValue < pointValues1->GetAt(i))
			{
				maxValue = pointValues1->GetAt(i);
			}
		}
		for(unsigned int i = 0; i < pointValues2->Size; i++)
		{
			if(maxValue < pointValues2->GetAt(i))
			{
				maxValue = pointValues2->GetAt(i);
			}
		}
		if(maxValue == 0.0)
			maxValue = 1.0;
		return maxValue;
	}

}